 package edu.zhang.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.zhang.dao.*;
import edu.zhang.po.*;

@WebServlet("/Back/admin/AdminUpdate")
public class AdminUpdate extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//System.out.println("nu");
		String id = request.getParameter("id");

		AdminDAO adminDAO = new AdminDAO();
		Admin admin  = adminDAO.getAdminById(Integer.parseInt(id));

		if (admin != null) {
			request.setAttribute("admin", admin);
			request.getRequestDispatcher("updateAdmin.jsp").forward(request, response);
		} else {
			response.sendRedirect("error.jsp");
		}
	}

}
